<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: add.phtml 3274 2010-06-04 09:19:33Z huuphuoc $
 */
?>
<?php
$this->headTitle($this->translator('attribute_add_page_title'));
$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/tomato/util.js');
?>

<div class="grid_12 t_a_ui_breadcrumb">
    <span><a href="<?php echo $this->url(array(), 'attribute_attribute_list'); ?>"><?php echo $this->translator('attribute_list_breadcump'); ?></a></span>
    <span><?php echo $this->translator('attribute_add_breadcump'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<form method="post" action="<?php echo $this->url(array(), 'attribute_attribute_add'); ?>" id="addAttributeForm">
<div class="grid_12 t_a_bottom"><?php echo $this->translator('attribute_add_guide'); ?></div>

<div class="grid_12 t_a_bottom">
    <div class="prefix_1 suffix_1">
        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('attribute_type_admin_name'); ?>:</label>
            <input type="text" id="attribute_type_admin_name" name="attribute_type_admin_name" style="width: 300px" />
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('attribute_category_name'); ?>:</label>
            <div style="border:1px solid #CCC; padding: 5px; width:300px;overflow:auto;height:120px">
                <?php for ($i = 0; $i < count($this->categories); $i++) : ?>
                    <input type="checkbox" id="category_id[]" name="category_id[]" value="<?php echo $this->categories[$i]->category_id; ?>"> <?php echo str_repeat('---', $this->categories[$i]->depth).$this->categories[$i]->category_admin_name; ?><br>
                <?php endfor; ?>
            </div>
        </div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label>&nbsp;</label>
            <button type="submit"><span><?php echo $this->translator('attribute_add_save_button'); ?></span></button>
        </div>
    </div>
</div>
</form>

<script type="text/javascript">
$(document).ready(function() {
    $('#addAttributeForm').validate({
        rules: {
            attribute_type_admin_name: {
                required: true,
                maxlength: 255
            },
            "category_id[]": "required"
        },
        messages: {
            attribute_type_admin_name: {
                required: "<?php echo $this->translator('attribute_name_required'); ?>",
                maxlength: "<?php echo $this->translator('attribute_name_maxlength'); ?>"
            },
            "category_id[]": "<?php echo $this->translator('attribute_category_id_required'); ?>"
        }
    });
});
</script>
